<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>快递设置</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link href="{__STATIC__}/layuiAdmin/layui/css/layui.css" rel="stylesheet">
	<link href="{__STATIC__}/layuiAdmin/adminui/dist/css/admin.css" rel="stylesheet">
	<link href="{__STATIC__}/layuiAdmin/style/style.css" rel="stylesheet">
	<style>
		.span_note,.span_note a {
			color: #999;
		}
		.span_note a:hover {
			text-decoration: underline;
		}
	</style>
</head>
<body>
<div class="layui-fluid">
	<form class="layui-form" style="padding-bottom: 45px;">
		<div class="layui-card">
			<div class="layui-card-body">
				<div class="layui-tab layui-tab-brief">
					<ul class="layui-tab-title">
						<li class="layui-this">快递设置</li>
					</ul>
					<div class="layui-tab-content">
						<div class="layui-tab-item layui-show">
							<div class="layui-form-item">
								<label class="layui-form-label">快递接口：</label>
								<div class="layui-input-inline w120">
									<select name="m_type">
										<option value="0" {eq name="$express.type" value="0"}selected{/eq}>ThinkApi</option>
									</select>
								</div>
								<div class="layui-form-mid layui-word-aux span_note"><a href="https://market.topthink.com/api" target="_blank">申请地址</a></div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label"><span>*</span> 访问令牌：</label>
								<div class="layui-input-inline">
									<input type="text" name="m_app_code" lay-verify="required" placeholder="请输入访问令牌" value="{$express.appCode}" class="layui-input">
								</div>
								<div class="layui-form-mid layui-word-aux span_note"><a href="https://console.topthink.com/user/token" target="_blank">个人中心-访问令牌中获取</a></div>
							</div>
							<div class="layui-form-item" style="display: none;">
								<label class="layui-form-label">appSecret：</label>
								<div class="layui-input-inline">
									<input type="text" name="m_app_secret" placeholder="请输入appSecret" value="{$express.appSecret}" class="layui-input">
								</div>
								<div class="layui-form-mid layui-word-aux"></div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">物流公司代码：</label>
								<div class="layui-input-inline w500">
									<textarea name="m_express" placeholder="顺丰速运|shunfeng" class="layui-textarea" style="height: 350px;line-height: 26px;">{$expressStr}</textarea>
								</div>
								<div class="layui-form-mid layui-word-aux span_note" style="line-height: 26px;">
									发货使用，一行一个。<br>如：顺丰速运|shunfeng
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="m_footer">
			<button class="layui-btn layui-btn-normal" lay-submit lay-filter="LAY-submit">提交</button>
			<button type="reset" class="layui-btn layui-btn-primary">重置</button>
		</div>
    </form>
</div>
<script src="{__STATIC__}/layuiAdmin/layui/layui.js"></script>
<script>
	layui.config({
		base: '{__STATIC__}/layuiAdmin/' // 静态资源所在路径
	}).use(['index','form'], function(){
		let $ = layui.$;
		let layer = layui.layer;
		let form = layui.form;

		/* 监听提交 */
		form.on('submit(LAY-submit)', function(data){
			let field = data.field; //获取提交的字段
			let m_express = field.m_express.replace(/\n/g,',');
			$.ajax({
				type:"post",
				url:"saveExpress.html",
				data: {
					m_type:field.m_type,
					m_app_code:field.m_app_code,
					m_app_secret:field.m_app_secret,
					m_express:m_express
				},
				dataType:"json",
				beforeSend: function () {
					layer.load(1);
				},
				success:function(res){
					layer.closeAll(); //关闭弹层
					if(res.code == 0){
						layer.msg('修改成功', {
							time: 2000
						}, function(){
							location.reload();
						});
					}
					else {
						layer.msg(res.msg);
					}
				}
			});
			return false;
		});
	});
</script>
</body>
</html>